/*
 * Copyright 2007-2009 Perttu "celeron55" Ahola <celeron55@gmail.com>
 *
 * This file is part of jukumagic.
 *
 * jukumagic is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * jukumagic is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with jukumagic.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef JUMPER_WIRE_H_
#define JUMPER_WIRE_H_

#include "common.h"
#include "jukuobject.h"
#include "boardobject.h"

class JumperWire : public JukuObject
{
	BoardSide m_side;
	int m_x1, m_y1;
	int m_x2, m_y2;
	wxString m_shortstring;
	//int m_last_select_checked_head;
	//int m_head_selected;
public:
	JumperWire();
	~JumperWire();
    JukuObjectType GetType(){ return TYPE_JUMPER_WIRE; }
	const wxChar * GetShortString(void){return m_shortstring;}
	const wxChar * GetTypeString(void){return _("JumperWire");}
	void WriteXML(TiXmlNode* root);
	static JukuObject* ReadFromXMLElement(TiXmlElement* element);
	void Draw(wxDC &dc, wxWindow *window, wxPoint origin);
	BoardRect GetDrawArea();
	BoardPoint GetBoardPos();
	void Move(int dx, int dy);

	int GetSide();
	void SetSide(BoardSide newside);
	bool IsSelectedInPoint(int x, int y);
	bool IsSelectedInArea(int x1, int y1, int x2, int y2, bool touch_is_enough);

	void SetSelected(bool selected);
	
	void Rotate(TurnDirection dir, BoardPoint origin);
	//void Rotate180();
	
	BoardRect GetPinExtents();

	//-1 if no head selected, possible heads are 1 and 2
	int GetHeadAtPoint(int x, int y);

	//void SelectHead(int head);

	BoardPoint GetHeadPoint(int head);
	void SetHeadPoint(int head, BoardPoint p);
};

#endif
